Also test scrolling to a new row in a mixed height model
authorKristian Rietveld <kris@gtk.org>
Thu, 14 Oct 2010 08:57:20 +0000 (10:57 +0200)
committerKristian Rietveld <kris@gtk.org>
Thu, 14 Oct 2010 14:47:00 +0000 (16:47 +0200)
gtk/tests/treeview-scrolling.c

index 90f8fea4927a1abb6a880087d90d75dfe5a67117..f29770ef8e6ba580f6c703476944852cb51fc73f 100644 (file)
@@ -210,6 +210,40 @@ scroll_fixture_tree_setup (ScrollFixture *fixture,
        scroll_fixture_setup (fixture, GTK_TREE_MODEL (store), test_data);
 }
 
+static void
+scroll_fixture_mixed_tree_setup (ScrollFixture *fixture,
+                                gconstpointer   test_data)
+{
+       GtkTreeStore *store;
+       GtkTreeIter iter, child;
+       int i;
+
+       store = gtk_tree_store_new (1, G_TYPE_STRING);
+
+       gtk_tree_store_append (store, &iter, NULL);
+       gtk_tree_store_set (store, &iter, 0, "Root\nnode", -1);
+
+       for (i = 0; i < 5; i++) {
+               gtk_tree_store_append (store, &child, &iter);
+               if (i % 2 == 0)
+                       gtk_tree_store_set (store, &child, 0, "Child node", -1);
+               else
+                       gtk_tree_store_set (store, &child,
+                                           0, "Child\nnode", -1);
+       }
+
+       for (i = 0; i < 5; i++) {
+               gtk_tree_store_append (store, &iter, NULL);
+               if (i % 2 != 0)
+                       gtk_tree_store_set (store, &iter, 0, "Other node", -1);
+               else
+                       gtk_tree_store_set (store, &iter, 0, "Other\nnode", -1);
+       }
+
+       /* The teardown will also destroy the model */
+       scroll_fixture_setup (fixture, GTK_TREE_MODEL (store), test_data);
+}
+
 static void
 scroll_fixture_teardown (ScrollFixture *fixture,
                         gconstpointer  test_data)
@@ -682,11 +716,21 @@ create_new_row (GtkListStore *store,
                        gtk_list_store_prepend (store, iter);
                        break;
 
+                case 3:
+                       /* Add a row in the middle of the visible area */
+                       gtk_list_store_insert (store, iter, 3);
+                       break;
+
                case 4:
                        /* Add a row in the middle of the visible area */
                        gtk_list_store_insert (store, iter, 4);
                        break;
 
+                case 5:
+                       /* Add a row which is not completely visible */
+                       gtk_list_store_insert (store, iter, 5);
+                       break;
+
                case 8:
                        /* Add a row which is not completely visible */
                        gtk_list_store_insert (store, iter, 8);
@@ -1186,6 +1230,43 @@ main (int argc, char **argv)
                    scroll_new_row_tree,
                    scroll_fixture_teardown);
 
+       /* Test scrolling to a newly created row, in a mixed height model */
+       g_test_add ("/TreeView/scrolling/new-row-mixed/path-0", ScrollFixture,
+                   GINT_TO_POINTER (0),
+                   scroll_fixture_mixed_setup,
+                   scroll_new_row,
+                   scroll_fixture_teardown);
+       g_test_add ("/TreeView/scrolling/new-row-mixed/path-3", ScrollFixture,
+                   GINT_TO_POINTER (3),
+                   scroll_fixture_mixed_setup,
+                   scroll_new_row,
+                   scroll_fixture_teardown);
+       /* We scroll to 8 to test a partial visible row.  The 8 is
+        * based on my font setting of "Vera Sans 11" and
+        * the separators set to 0.  (This should be made dynamic; FIXME).
+        */
+       g_test_add ("/TreeView/scrolling/new-row-mixed/path-5", ScrollFixture,
+                   GINT_TO_POINTER (5),
+                   scroll_fixture_mixed_setup,
+                   scroll_new_row,
+                   scroll_fixture_teardown);
+       g_test_add ("/TreeView/scrolling/new-row-mixed/path-500", ScrollFixture,
+                   GINT_TO_POINTER (500),
+                   scroll_fixture_mixed_setup,
+                   scroll_new_row,
+                   scroll_fixture_teardown);
+       g_test_add ("/TreeView/scrolling/new-row-mixed/path-999", ScrollFixture,
+                   GINT_TO_POINTER (999),
+                   scroll_fixture_mixed_setup,
+                   scroll_new_row,
+                   scroll_fixture_teardown);
+
+       g_test_add ("/TreeView/scrolling/new-row-mixed/tree", ScrollFixture,
+                   NULL,
+                   scroll_fixture_mixed_tree_setup,
+                   scroll_new_row_tree,
+                   scroll_fixture_teardown);
+
        /* Misc. tests */
        g_test_add ("/TreeView/scrolling/specific/bug-316689",
                        ScrollFixture, NULL,